home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 8 / Eagles_Nest_Mac_Collection_Disc_8.TOAST / Developer Tools⁄Additions / InsideBa1994 / InsideBasic-94 / IB 94 / Simple DB / Key.FLTR < prev    next >
Text File  |  1993-10-23  |  11KB  |  420 lines

  1. '===============================================================================
  2. '=                         Copyright 1992 Staz™ Software, Inc.                 =
  3. '=                               All rights reserved                           =
  4. '=                             "Key.FLTR" from PG:PRO                        =
  5. '===============================================================================
  6. INCLUDE FILE _aplIncl
  7. COMPILE 0,_MacsbugLabels_strResource_caseInsensitive'set by PG:PRO
  8. GLOBALS "PG PRO.GLBL"'include standard global file
  9. END GLOBALS'no other globals
  10. GOTO "Key Filter:Start"'ALWAYS jump around functions
  11. INCLUDE "@Header.INCL"
  12. DEFSTR LONG'needed for CVI's
  13.  
  14. _KFrepairField  = 2000
  15. _KFMMDDYY       = 1'08/15/92
  16. _KFMMYY         = 2'08/92
  17. _KFCAPS         = 3'UCASE$
  18. _KFWordCaps     = 4'word caps
  19. _KFHex          = 5'hexidecimal
  20. _KFIntegers     = 6'0123456789-
  21. _KFDecimals     = 7'0123456789.-
  22. _KFCAPSnDigits  = 8'A-Z and 0-9
  23. _KFDollars      = 9'0123456789.-$
  24. _KFCustom1      = 10'build your own(1)
  25. _KFCustom2      = 11'build your own(2)
  26. _KFCustom3      = 12'build your own(3)
  27. _KFCustom4      = 13'build your own(4)
  28. _KFCustom5      = 14'build your own(5)
  29. '_______________________________________________________________________________
  30. LOCAL FN KFstrip$(theText$)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  31. '—————————————————————————————————————————————————————————————————————————————
  32. xtract$ = ""
  33. FOR x = 1 TO LEN(theText$)
  34. char = PEEK(@theText$+x)
  35. LONG IF char <> 32
  36. xtract$ =xtract$ + CHR$(char)
  37. END IF
  38. NEXT
  39. END FN = xtract$
  40. '_______________________________________________________________________________
  41. LOCAL FN KFdateFld'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  42. '—————————————————————————————————————————————————————————————————————————————
  43. TEKEY$ = gKey$:gKey$ = ""
  44. oldInsPt = WINDOW(_selStart)
  45. theDate$ = EDIT$(WINDOW(_EFnum))
  46. theDate$ = UCASE$(theDate$)
  47. mm = 0:yy = 0:dd = 0:chop = 0
  48. newDate$ = ""
  49. theDate$ = FN KFstrip$(theDate$)
  50. IF LEFT$(theDate$,1) = "0" THEN theDate$ = MID$(theDate$,2)
  51.  
  52. SELECT PEEK(@theDate$+1)
  53. CASE _"J"'Jan/June/July
  54. LONG IF LEFT$(theDate$,2)="JA"
  55. mm=1:chop=2'jan
  56. XELSE
  57. SELECT LEFT$(theDate$,3)'
  58. CASE "JUN":mm=6:chop=3'june
  59. CASE "JUL":mm=7:chop=3'july
  60. END SELECT'
  61. END IF
  62. CASE _"F":mm=2:chop=1'Feb
  63. CASE _"M"'March/May
  64. SELECT LEFT$(theDate$,3)'
  65. CASE "MAR":mm=3:chop=3'march
  66. CASE "MAY":mm=5:chop=3'may
  67. END SELECT'
  68. CASE _"A"'April/Aug
  69. SELECT LEFT$(theDate$,2)'
  70. CASE "AP":mm=4:chop=2'april
  71. CASE "AU":mm=8:chop=2'aug
  72. END SELECT'
  73. CASE _"S":mm=9 :chop=1'Sept
  74. CASE _"O":mm=10:chop=1'Oct
  75. CASE _"N":mm=11:chop=1'Nov
  76. CASE _"D":mm=12:chop=1'dec
  77. CASE _"1"'jan,oct,nov,dec
  78. LONG IF LEN(theDate$)>1
  79. SELECT PEEK(@theDate$+2)'
  80. CASE _"0":mm=10:chop=2'oct
  81. CASE _"1":mm=11:chop=2'nov
  82. CASE _"2":mm=12:chop=2'dec
  83. CASE ELSE:mm=1:chop=1
  84. END SELECT'
  85. XELSE
  86. theDate$ = ""'can't figure yet
  87. END IF
  88. CASE _"2":mm=2:chop=1'feb
  89. CASE _"3":mm=3:chop=1'mar
  90. CASE _"4":mm=4:chop=1'apr
  91. CASE _"5":mm=5:chop=1'may
  92. CASE _"6":mm=6:chop=1'jun
  93. CASE _"7":mm=7:chop=1'jul
  94. CASE _"8":mm=8:chop=1'aug
  95. CASE _"9":mm=9:chop=1'sept
  96. END SELECT
  97.  
  98. LONG IF mm
  99. newDate$ = "0"+MID$(STR$(mm),2)+"/"
  100. newDate$ = RIGHT$(newDate$,3)
  101. theDate$ = MID$(theDate$,chop+1)
  102. chop = 0
  103. END IF
  104.  
  105. DO
  106. flag = _zTrue
  107. LONG IF LEN(theDate$)
  108. LONG IF PEEK(@theDate$+1)<_"1" OR PEEK(@theDate$+1)>_"9"
  109. theDate$ = MID$(theDate$,2)
  110. flag = _false
  111. END IF
  112. END IF
  113. UNTIL flag
  114.  
  115. IF theDate$ = "" THEN "Date Key Done"
  116. SELECT PEEK(@theDate$+1)
  117. CASE > _"3"
  118. dd = PEEK(@theDate$+1)-48
  119. theDate$ = MID$(theDate$,2)
  120. CASE ELSE
  121. LONG IF LEN(theDate$)>1
  122. dd = VAL(theDate$)
  123. DO
  124. flag = _zTrue
  125. LONG IF LEN(theDate$)
  126. LONG IF PEEK(@theDate$+1)=>_"1" AND PEEK(@theDate$+1)<=_"9"
  127. theDate$ = MID$(theDate$,2)
  128. flag = _false
  129. END IF
  130. END IF
  131. UNTIL flag
  132. XELSE
  133. newDate$ = newDate$ + theDate$
  134. theDate$ = ""
  135. END IF
  136. END SELECT
  137.  
  138. LONG IF dd
  139. SELECT mm
  140. CASE 9,4,6,11
  141. IF dd > 30 THEN dd = 30
  142. CASE 2
  143. IF dd > 29 THEN dd = 29
  144. CASE ELSE
  145. IF dd > 31 THEN dd = 31
  146. END SELECT
  147. t$ = "0"+MID$(STR$(dd),2)+"/"
  148. newDate$ = newDate$ + RIGHT$(t$,3)
  149. END IF
  150.  
  151. LONG IF LEN(newDate$)
  152. DO
  153. flag = _zTrue
  154. LONG IF LEN(theDate$)
  155. LONG IF PEEK(@theDate$+1)<_"1" OR PEEK(@theDate$+1)>_"9"
  156. theDate$ = MID$(theDate$,2)
  157. flag = _false
  158. END IF
  159. END IF
  160. UNTIL flag
  161.  
  162. yy = VAL(theDate$)
  163. LONG IF yy
  164. t$ = MID$(STR$(yy),2)
  165. IF LEN(t$)>2 THEN t$ = RIGHT$(t$,2)
  166. newDate$ = newDate$ + t$
  167. END IF
  168. END IF
  169.  
  170. "Date Key Done"
  171. LONG IF LEN(newDate$)
  172. EDIT$(WINDOW(_EFnum)) = newDate$
  173. SETSELECT WINDOW(_EFTextLen),WINDOW(_EFTextLen)
  174. END IF
  175. END FN
  176. '_______________________________________________________________________________
  177. LOCAL FN KFmonthFld'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  178. '—————————————————————————————————————————————————————————————————————————————
  179.  
  180. TEKEY$ = gKey$:gKey$ = ""
  181. theDate$ = EDIT$(WINDOW(_EFnum))
  182. theDate$ = UCASE$(theDate$)
  183. mm = 0:yy = 0:dd = 0:chop = 0
  184. newDate$ = ""
  185. theDate$ = FN KFstrip$(theDate$)
  186. IF LEFT$(theDate$,1) = "0" THEN theDate$ = MID$(theDate$,2)
  187. SELECT PEEK(@theDate$+1)
  188. CASE _"J"'Jan/June/July
  189. LONG IF LEFT$(theDate$,2)="JA"
  190. mm=1:chop=2'jan
  191. XELSE
  192. SELECT LEFT$(theDate$,3)'
  193. CASE "JUN":mm=6:chop=3'june
  194. CASE "JUL":mm=7:chop=3'july
  195. END SELECT'
  196. END IF
  197. CASE _"F":mm=2:chop=1'Feb
  198. CASE _"M"'March/May
  199. SELECT LEFT$(theDate$,3)'
  200. CASE "MAR":mm=3:chop=3'march
  201. CASE "MAY":mm=5:chop=3'may
  202. END SELECT'
  203. CASE _"A"'April/Aug
  204. SELECT LEFT$(theDate$,2)'
  205. CASE "AP":mm=4:chop=2'april
  206. CASE "AU":mm=8:chop=2'aug
  207. END SELECT'
  208. CASE _"S":mm=9 :chop=1'Sept
  209. CASE _"O":mm=10:chop=1'Oct
  210. CASE _"N":mm=11:chop=1'Nov
  211. CASE _"D":mm=12:chop=1'dec
  212. CASE _"1"'jan,oct,nov,dec
  213. LONG IF LEN(theDate$)>1
  214. SELECT PEEK(@theDate$+2)'
  215. CASE _"0":mm=10:chop=2'oct
  216. CASE _"1":mm=11:chop=2'nov
  217. CASE _"2":mm=12:chop=2'dec
  218. CASE ELSE:mm=1:chop=1
  219. END SELECT'
  220. XELSE
  221. theDate$ = ""'can't figure yet
  222. END IF
  223. CASE _"2":mm=2:chop=1'feb
  224. CASE _"3":mm=3:chop=1'mar
  225. CASE _"4":mm=4:chop=1'apr
  226. CASE _"5":mm=5:chop=1'may
  227. CASE _"6":mm=6:chop=1'jun
  228. CASE _"7":mm=7:chop=1'jul
  229. CASE _"8":mm=8:chop=1'aug
  230. CASE _"9":mm=9:chop=1'sept
  231. END SELECT
  232.  
  233. LONG IF mm
  234. newDate$ = "0"+MID$(STR$(mm),2)+"/"
  235. newDate$ = RIGHT$(newDate$,3)
  236. theDate$ = MID$(theDate$,chop+1)
  237. chop = 0
  238. END IF
  239. IF theDate$ = "" THEN "Expire Key Done"
  240.  
  241. DO
  242. flag = _zTrue
  243. LONG IF LEN(theDate$)
  244. LONG IF PEEK(@theDate$+1)<_"1" OR PEEK(@theDate$+1)>_"9"
  245. theDate$ = MID$(theDate$,2)
  246. flag = _false
  247. END IF
  248. END IF
  249. UNTIL flag
  250.  
  251. IF theDate$ = "" THEN "Expire Key Done"
  252.  
  253. LONG IF LEN(newDate$)
  254. DO
  255. flag = _zTrue
  256. LONG IF LEN(theDate$)
  257. LONG IF PEEK(@theDate$+1)<_"1" OR PEEK(@theDate$+1)>_"9"
  258. theDate$ = MID$(theDate$,2)
  259. flag = _false
  260. END IF
  261. END IF
  262. UNTIL flag
  263.  
  264. yy = VAL(theDate$)
  265. LONG IF yy
  266. t$ = MID$(STR$(yy),2)
  267. IF LEN(t$)>2 THEN t$ = RIGHT$(t$,2)
  268. newDate$ = newDate$ + t$
  269. END IF
  270. END IF
  271.  
  272. "Expire Key Done"
  273. LONG IF LEN(newDate$)
  274. EDIT$(WINDOW(_EFnum)) = newDate$
  275. SETSELECT WINDOW(_EFTextLen),WINDOW(_EFTextLen)
  276. END IF
  277.  
  278. END FN
  279. '_______________________________________________________________________________
  280. LOCAL FN KFexitFld'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  281. '—————————————————————————————————————————————————————————————————————————————
  282. thefld = WINDOW(_EFnum)
  283. theClass = WINDOW(_EFClass)>>2
  284. SELECT theClass
  285. CASE _KFDollars:'currency text field
  286. t$ = EDIT$(thefld)
  287. xtract$ = ""
  288. IF ASC(t$) = _"(" THEN negate = _zTrue ELSE negate = _false
  289. FOR x = 1 TO LEN(t$)
  290. char = PEEK(@t$+x)
  291. LONG IF (char > 47 AND char < 58) OR char = _"." OR char = _"-"
  292. xtract$ = xtract$ + CHR$(char)
  293. END IF
  294. NEXT
  295. amnt! = VAL(xtract$) + 0.
  296. t$ = USING "###,###,###.##";(amnt!)
  297. WHILE LEFT$(t$,1) = " " OR LEFT$(t$,1) = ","
  298. t$ = MID$(t$,2)
  299. WEND
  300. t$ = "$" + t$
  301. LONG IF amnt! < 0 OR negate = _zTrue
  302. t$ = "(" +  t$ + ")"
  303. EDIT FIELD thefld, t$
  304. EDIT TEXT ,,,,-1,0,0
  305. XELSE
  306. EDIT TEXT ,,,,0,0,0
  307. EDIT$(thefld) = t$
  308. END IF
  309.  
  310. CASE _KFCAPS'UCASE$
  311. CASE _KFWordCaps'word caps
  312. CASE _KFHex'hexidecimal
  313. CASE _KFMMDDYY'MM/DD/YY
  314. t$ = gKey$
  315. gKey$ = ""
  316. FN KFdateFld
  317. gKey$ = t$
  318. CASE _KFIntegers'0-9 and minus (-)
  319. CASE _KFDecimals'0123456789.-
  320. CASE _KFMMYY'month & year exp date
  321. CASE _KFCAPSnDigits'A-Z 0-9 Caps only
  322. CASE _KFCustom1
  323. CASE _KFCustom2
  324. CASE _KFCustom3
  325. CASE _KFCustom4
  326. CASE _KFCustom5
  327. END SELECT
  328. END FN
  329. '_______________________________________________________________________________
  330. LOCAL FN KFfilterKey'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑
  331. '—————————————————————————————————————————————————————————————————————————————
  332. key = PEEK(@gKey$+1)
  333. LONG IF key > 31 AND key < 127'don't mess w/ arrows,del,rtn
  334. theClass = WINDOW(_EFClass)>>2
  335. SELECT theClass
  336. CASE _KFDollars:'currency text field
  337. LONG IF INSTR(1,"$-.0123456789()",gKey$) = 0
  338. gKey$ = ""
  339. END IF
  340. :'--------------------------
  341. CASE _KFCAPS'capitals only
  342. gKey$ = UCASE$(gKey$)
  343. :'--------------------------
  344. CASE _KFWordCaps'word caps
  345. LONG IF WINDOW(_selStart) = 0
  346. gKey$ = UCASE$(gKey$)
  347. XELSE
  348. prevChar = PEEK([FN TEGETTEXT(WINDOW(_EFHandle))]+WINDOW(_selStart)-1)
  349. IF prevChar = 32 THEN gKey$ = UCASE$(gKey$)
  350. END IF
  351. :'--------------------------
  352. CASE _KFHex'hexidecimal
  353. gKey$ = UCASE$(gKey$)
  354. LONG IF INSTR(1,"$&0123456789ABCDEF",gKey$) = 0
  355. gKey$ = ""
  356. END IF
  357. :'--------------------------
  358. CASE _KFMMDDYY'MM/DD/YY
  359. FN KFdateFld
  360. :'--------------------------
  361. CASE _KFIntegers'0-9 and minus (-)
  362. LONG IF INSTR(1,"0123456789-",gKey$) = 0
  363. gKey$ = ""
  364. END IF
  365. :'--------------------------
  366. CASE _KFDecimals'0123456789.-
  367. LONG IF INSTR(1,"0123456789.-",gKey$) = 0
  368. gKey$ = ""
  369. END IF
  370. :'--------------------------
  371. CASE _KFMMYY'month & year exp date
  372. FN KFmonthFld
  373. :'--------------------------
  374. CASE _KFCAPSnDigits'A-Z 0-9 Caps only
  375. gKey$ = UCASE$(gKey$)
  376. LONG IF INSTR(1,"0123456789",gKey$) = 0
  377. LONG IF PEEK(@gKey$+1)<_"A" OR PEEK(@gKey$+1)>_"Z"
  378. gKey$ = ""
  379. END IF
  380. END IF
  381. :'--------------------------
  382. CASE _KFCustom1
  383. CASE _KFCustom2
  384. CASE _KFCustom3
  385. CASE _KFCustom4
  386. CASE _KFCustom5
  387. END SELECT
  388. END IF
  389. END FN
  390. '===============================================================================
  391. '››››››››››                      FIELD FILTER                       ››››››››››
  392. '===============================================================================
  393. "Key Filter:Start"
  394. SELECT gAction
  395. CASE _mouseAction
  396. CASE _fieldAction
  397. SELECT gSubAction
  398. CASE _fieldActivate
  399. EDIT FIELD gFieldWas:FN KFexitFld
  400. EDIT FIELD gWhichField
  401. CASE _fieldChanging   :DIALOG = _KFrepairField
  402. CASE _fieldKeyPressed :FN KFfilterKey
  403. CASE _fieldReturn     :FN KFexitFld
  404. CASE _fieldTab        :FN KFexitFld
  405. CASE _fieldShiftTab   :FN KFexitFld
  406. CASE _fieldClear
  407. CASE _fieldLeft       :FN KFexitFld
  408. CASE _fieldRight      :FN KFexitFld
  409. CASE _fieldUp         :FN KFexitFld
  410. CASE _fieldDown       :FN KFexitFld
  411. CASE _fieldClicked
  412. END SELECT
  413. CASE _otherAction
  414. LONG IF gSubAction = _otherUser
  415. LONG IF gDialogValue = _KFrepairField
  416. FN KFexitFld
  417. END IF
  418. END IF
  419. END SELECT
  420. '-------------------------------------------------------------------------------